package com.hgk.common.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import width.hgk.wanwan.R;

/**
 * Created by lenovo on 2016/9/22.
 * 自定义标题框
 */
public class UIHeaderView extends LinearLayout{
    private Button btn_left,btn_right;
    private TextView tv_title;
    public UIHeaderView(Context context) {
        super(context);
    }

    public UIHeaderView(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        layoutInflater.inflate(R.layout.wherefrag_header,null);
        btn_left = (Button) findViewById(R.id.btn_left_header);
        btn_right = (Button) findViewById(R.id.btn_right_header);
        tv_title = (TextView) findViewById(R.id.tv_wherefrag_title);
    }

    //设置按钮背景
    public void setBtnRightBackground(int resId){
        if (btn_right!=null){
            btn_right.setBackgroundResource(resId);
        }
    }
    public void setBtnLeftBacground(int resId){
        if (btn_left !=null){
            btn_left.setBackgroundResource(resId);
        }
    }

    //设置按钮文本
    public void setBtnRightText(String str){
        if (btn_right!=null){
            btn_right.setText(str);
        }
    }
    public void setBtnLeftText(String str){
        if (btn_right!=null){
            btn_right.setText(str);
        }
    }
    //设置标题背景
    public void setTvTitleBackground(int resId) {
        if (tv_title != null) {
            tv_title.setText(resId);
        }
    }

    //设置标题文本
    public void setTitleText(String str){
        if (tv_title!=null){
            tv_title.setText(str);
        }
    }
    public Button getBtn_left() {
        return btn_left;
    }

    public Button getBtn_right() {
        return btn_right;
    }

    public TextView getTv_title() {
        return tv_title;
    }

}
